﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;

namespace TimeCapsule
{
	public class Mail
	{
		public Mail()
		{

		}
		
		public static void SendAuthenticationMail(string email, string name, string key)
		{
			string content = @"본인 확인 인증좀 부탁드리겠습니다. " + name + @"님
									이것좀 클릭 해주세요 <a href='http://localhost:57094/TimeCapsule/Auth.aspx?type=0&key=" + key + @"'>
									http://localhost:57094/TimeCapsule/Auth.aspx?type=0&key=" + key + @"</a>";
			Mail m = new Mail();
			m.Send(email, "인증 요청 메일", content);
		}
		
		public void Send(string to, string title, string body)
		{
			MailMessage mail = new MailMessage();
			mail.To.Add(to);
			mail.From = new MailAddress("ekagud@gmail.com");
			mail.Subject = title;
			mail.Body = body;

			mail.IsBodyHtml = true;

			SmtpClient smtp = new SmtpClient();
			smtp.Host = "smtp.gmail.com";
			smtp.Credentials = new System.Net.NetworkCredential("ekagud@gmail.com", "ekaguddl");
			smtp.EnableSsl = true;
			smtp.Send(mail);
		}
		
		public void Send(string[] to, string title, string body)
		{
			MailMessage mail = new MailMessage();
			foreach (string addr in to)
			{
				mail.To.Add(addr);
			}
			mail.From = new MailAddress("ekagud@gmail.com");
			mail.Subject = title;
			mail.Body = body;

			mail.IsBodyHtml = true;

			SmtpClient smtp = new SmtpClient();
			smtp.Host = "smtp.gmail.com";
			smtp.Credentials = new System.Net.NetworkCredential("ekagud@gmail.com", "ekaguddl");
			smtp.EnableSsl = true;
			smtp.Send(mail);
		}
	}
}
